// 导入 express
const express = require('express')
const expressJoi = require('@escook/express-joi')
// 创建路由对象
const router = express.Router()

const {getArticleCates, addArticleCates,deleteCateById, getArticleById, updatecate} = require('../router_handler/artcate')
 
const { add_cate_schema, delete_cate_schema, get_cate_schema, update_cate_schema} = require('../schema/artcate')

// 获取文章分类的列表数据
router.get('/cates', getArticleCates)

//新增文章分类
router.post('/addcates',expressJoi(add_cate_schema),addArticleCates)

//删除文章分类路由
router.get('/deletecate/:id',expressJoi(delete_cate_schema), deleteCateById)

//根据 id 获取文章分类数据
router.get('/cates/:id',expressJoi(get_cate_schema),getArticleById)

//根据 id 更新文章分类数据
router.put('/updatecate',expressJoi(update_cate_schema),updatecate)

// 向外共享路由对象
module.exports = router